package drawingManagement;

import loginTest.Login;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.openqa.selenium.By;

import static java.lang.Thread.sleep;

public class FindDrawName extends Login {
    @Override
    @ParameterizedTest
    @CsvSource("https://ceshi.cadexam.com:5555/resource-platform/#/login?redirect=/resource/title/titlemanage,15172344500,15172344500,http://192.168.61.142:11280/resource-platform/#/resource/title/titlemanage")
    @Order(1)
    public void login(String url, String username, String password, String newUrl) throws InterruptedException {
        super.login(url, username, password, newUrl);
    }
    /*
        使用图纸名称查找
     */
    @ParameterizedTest
    @CsvSource("测试")
    @Order(3)
    void findID(String name) throws InterruptedException {
        //打开左侧栏
//        webDriver.findElement(By.cssSelector("#hamburger-container")).click();
        //选择图纸管理
        webDriver.findElement(By.cssSelector("#app > div > div.has-logo.sidebar-container > div.el-scrollbar.theme-dark > div.scrollbar-wrapper.el-scrollbar__wrap.el-scrollbar__wrap--hidden-default > div > ul > div:nth-child(2) > li > div")).click();
        sleep(1000);
        webDriver.findElement(By.cssSelector("#app > div > div.has-logo.sidebar-container > div.el-scrollbar.theme-dark > div.scrollbar-wrapper.el-scrollbar__wrap.el-scrollbar__wrap--hidden-default > div > ul > div:nth-child(2) > li > ul > div:nth-child(1)"))
                .click();
        sleep(1000);
        //输入图纸名称
        webDriver.findElement(By.xpath("/html/body/div[1]/div/div[2]/section/div/div/form/div[2]/div/div/div/div/input")).sendKeys(name);
        sleep(1000);
        //点击查询
        webDriver.findElement(By.cssSelector("#app > div > div.hasTagsView.main-container > section > div > div > form > div.panel-item.search-btn > button:nth-child(1)")).click();
        sleep(1000);
        String ans = webDriver.findElement(By.cssSelector("#app > div > div.hasTagsView.main-container > section > div > div > div.table-area > div.pagination-container > div > span.el-pagination__total.is-first")).getText();
        System.out.println("查询到:"+ans+"数据");
        Assertions.assertNotEquals("共 0 条",ans);
    }
}
